{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 文字输入api"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'reason': 'success',\n",
       " 'result': [{'id': '3160', 'itemName': '西瓜皮', 'itemCategory': '湿垃圾'}],\n",
       " 'error_code': 0}"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import requests\n",
    "import base64\n",
    "import pandas as pd\n",
    "import json\n",
    "host = \"http://apis.juhe.cn/rubbish/search?key=6454d30fe5cab34a31aee83ad6f7abd3&q=西瓜皮\"\n",
    "\n",
    "params = {\n",
    "    \"type\":2\n",
    "}\n",
    "response = requests.post(host,data=params)\n",
    "response.json()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 图像识别api"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'reason': 'success',\n",
       " 'result': [{'score': 0.999989,\n",
       "   'keyword': '西瓜',\n",
       "   'list': [{'id': '3830', 'itemName': '西瓜', 'itemCategory': '湿垃圾'}]},\n",
       "  {'score': 0.770251, 'keyword': '石莱西瓜', 'list': None},\n",
       "  {'score': 0.496936, 'keyword': '地雷瓜', 'list': None}],\n",
       " 'error_code': 0}"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import requests\n",
    "import base64\n",
    "import pandas as pd\n",
    "import json\n",
    "host = \"http://apis.juhe.cn/voiceRubbish/imgDisti?key=26e121785a0d97f04d5d44b0b4ede050\"\n",
    "f = open(r'C:\\Users\\86184\\Desktop\\相册\\西瓜.jpg', 'rb')\n",
    "img = base64.b64encode(f.read())\n",
    "params = {\n",
    "    \"image\":img,\n",
    "    \"type\":2\n",
    "}\n",
    "response = requests.post(host,data=params)\n",
    "response.json()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 语音输入api"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'reason': 'success',\n",
       " 'result': {'speechText': '塑料袋',\n",
       "  'list': [{'id': '615', 'itemName': '塑料袋', 'itemCategory': '干垃圾'}]},\n",
       " 'error_code': 0}"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import requests\n",
    "import base64\n",
    "import pandas as pd\n",
    "import json\n",
    "host = \"http://apis.juhe.cn/voiceRubbish/disti?key=26e121785a0d97f04d5d44b0b4ede050\"\n",
    "f = open(r'C:\\Users\\86184\\Downloads\\rubbish.pcm', 'rb')\n",
    "speech = base64.b64encode(f.read())\n",
    "params = {\n",
    "    \"speech\": speech,\n",
    "    \"type\": 2\n",
    "}\n",
    "response = requests.post(host,data=params)\n",
    "response.json()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 垃圾分类知识api"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'reason': 'success',\n",
       " 'result': [{'id': '1',\n",
       "   'name': '可回收物',\n",
       "   'explain': '废纸张、废塑料、废玻璃制品、废金属、废织物等适宜回收、可循环利用的生活废弃物',\n",
       "   'require': '轻投轻放；清洁干燥，避免污染；废纸尽量平整；立体包装物请清空内容物，清洁后压扁投放；有尖锐边角的，应包裹后投放',\n",
       "   'common': '报纸、纸箱、书本、纸袋、塑料瓶、玩具、油桶、乳液罐、食品保鲜盒、衣架、酒瓶、玻璃杯、易拉罐、锅、螺丝刀、皮鞋、衣物、包、毛绒玩具、电路板、砧板、插座'},\n",
       "  {'id': '2',\n",
       "   'name': '有害垃圾',\n",
       "   'explain': '对人体健康或自然环境造成直接或潜在的危害废弃物。',\n",
       "   'require': '充电电池、纽扣电池、蓄电池投放时应注意轻放；油漆桶、杀虫剂如有残留请密闭后投放；荧光灯、节能灯易破损连带包装或包裹后投放；废药品及其包装一并投放',\n",
       "   'common': '电池类、荧光灯管类、过期药物、药品包装、过期指甲油、指甲水、染发剂壳、废油漆桶、水银体温计/血压计、消毒剂、老鼠药、杀虫喷雾、X光片、相片底片'},\n",
       "  {'id': '3',\n",
       "   'name': '湿垃圾',\n",
       "   'explain': '部分地区又称”厨余垃圾”，日常生活垃圾产生的容易腐烂的生物质废物。',\n",
       "   'require': '餐厨垃圾应沥干水分后再投放，有包装物的应取出后分类投放；大块骨头和椰子壳，榴莲壳等不易生化降解，作为干垃圾进行投放；纯液体（如牛奶等），可直接倒入下水口',\n",
       "   'common': '剩饭剩菜、面包、鸡肉、干果仁、蔬菜、花卉、蛋糕饼干、动物内脏、苹果核、鸡蛋及蛋壳、大米及豆类、中药药渣、宠物饲料'},\n",
       "  {'id': '4',\n",
       "   'name': '干垃圾',\n",
       "   'explain': '部分地区又称”其他垃圾”，除有害垃圾、可回收物、湿垃圾以外的生活废弃物。',\n",
       "   'require': '尽量沥干水分；难以辨别的生活垃圾应投入干垃圾容器内',\n",
       "   'common': '餐巾纸、纸巾、纸尿裤、烟蒂、陶瓷花盆、胶带、橡皮泥、创可贴、笔、灰土、眼镜、头发、内衣裤、防碎气泡膜、旧毛巾、污损纸张、塑料袋'}],\n",
       " 'error_code': 0}"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import requests\n",
    "import base64\n",
    "import pandas as pd\n",
    "import json\n",
    "host = \"http://apis.juhe.cn/rubbish/category?key=6454d30fe5cab34a31aee83ad6f7abd3\"\n",
    "params = {\n",
    "    \"type\":2\n",
    "}\n",
    "response = requests.post(host,data=params)\n",
    "response.json()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
